<?php
/*
 * This is user operations page.
 */

class Usr {

    function __construct() {
        include '../config.php';
    }

    function block_user($uid) {
        mysql_query("update fa_user set banned=1 where id=$uid ") or die(mysql_error());

        echo 'Blocked';
    }

    function approve_user($uid) {
        mysql_query("update fa_user set banned=0 where id=$uid ") or die(mysql_error());
        echo 'UnBlocked';
    }

    function get_buy_details($product_id) {
        $result = mysql_query("select * from salus_buy_detail where FK_fa_product_id = $product_id ") or die(mysql_error());
        return $result;
    }

    function get_user_by_subs($sub_id, $sub_year) {
        echo '<h2>' . $sub_year . '</h2><hr>';
       
        ?>
        <div class="table"  >
            <img src="img/bg-th-left.gif" width="8" height="7" alt="" class="left" />
            <img src="img/bg-th-right.gif" width="7" height="7" alt="" class="right" />
            <table class="listing" cellpadding="0" cellspacing="0">
                <tr>
                    <th class="first" width="20px">Sr No.</th>
                    <th width="100" >Username</th>
                    <th width="100" >Email</th>
                    <th width="100" >Actions</th>
                </tr>
                <?php $i = 1;
                $query = mysql_query("select FK_fa_user_id from salus_buy_product where buy_detail_id = $sub_id ") or die(mysql_error());
                while ($row = mysql_fetch_array($query)) {
                    $uid = $row['FK_fa_user_id'];
                    $getsuer = mysql_query("select * from fa_user where id= $uid ") or die(mysql_error());                    
                    while ($row1 = mysql_fetch_array($getsuer)) {                        
                        ?>
                        <tr class="bg">
                            <td class="first style1"><?php echo $i;?>  </td>                               
                            <td><?= $row1['user_name'] ?></td>
                            <td><?= $row1['email'] ?></td>
                            <td class="last">
                                <a href="users.php?p=view&id=<?= $row1['id'] ?>"><img src="img/view.gif" height="20" width="20" title="View User Profile"  /></a>
                                <?php
                                if ($row1['banned'] == '1') {
                                    echo '<a href=users?p=a&id=' . $uid . '><img src="img/approve.jpg" title="Un Block User" /></a>';
                                } else {
                                    echo '<a href=users?p=b&id=' . $uid . '><img src="img/banned.jpg" title="Block User" /></a>';
                                }
                                ?>
                <!--                                                        <img src="img/delete.png" height="20" width="20" title="Delete This User" />-->
                            </td>
                        </tr>
                    <?php
                    $i++;
                    }
                }
                ?>
            </table>
        </div>
        <?php
    }

//function get_user_by_subs over

    function get_user($user_id) {
        
        return $query;
    }

}

//class over
?>
